<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>


<style>
  div.ex1 {
    width: 300px;
    background-color: lightsteelblue;
  }

  div.ex2 {
    width: 300px;
    padding: 25px;
    background-color: lightgrey;
  }
</style>


<body>
  <h1>内边距和元素宽度</h1>
  <div class="ex1">这个div是300像素宽</div>
  <br>
  <div class="ex2">这个div是350像素宽，即使在css中他被定义为300像素</div>
</body>

</html>